package com.TheyChat.service.config.core.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

/***
 * 是否值枚举
 */
@AllArgsConstructor
public enum YesNoEnum implements BaseEnum {
    YES(1, "是"),
    NO(0, "否");

    @EnumValue
    private Integer value;
    @Getter
    private String desc;
    /**
     * 序列化
     *
     * @return 不允许返回 null
     */
    @Override
    public Integer getValue() {
        return this.value;
    }

    @JsonCreator
    public static YesNoEnum findYesNoEnum(Integer value){
        for (YesNoEnum item : YesNoEnum.values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }
        return null;
    }
}
